#! /bin/bash

# sync onvif-server project from svn to git
# simple copy source files to git every time.
#  $1 -- commit log message

SVN_DIR=$HOME/work/onvif/svn/onvif
GIT_DIR=$HOME/work/onvif/myonvif/onvif-server

SUB_DIRS="services"
EXT_FILES="Makefile Makefile.param onvif.config onvif.nsmap"
SRC_FILES="*.c *.h"

# copy files in the top folder
for file in $EXT_FILES
do
	cp $SVN_DIR/$file $GIT_DIR
done

file=
for file in $SRC_FILES
do
	cp $SVN_DIR/$file $GIT_DIR
done

# copy sub directories
for subdir in $SUB_DIRS
do
	cp -a $SVN_DIR/$subdir $GIT_DIR
done

# commit changes and sync log messages
if [ $PWD == $SVN_DIR ]
then
	svn commit -m $1
	pushd $GIT_DIR
	git add .
	git commit -a -m $1
	popd
fi


